#/bin/bash
set -x

latest=`wget --no-proxy -qO /dev/stdout http://jenkins.sumilux.com:8108/job/tigase-production/ws/tigase-version-lkg`
version=${1:-$latest}

BASE=/opt/tigase

. functions.sh
download_file smx-agg-tigase.$version.tgz /tmp

(cd ${BASE} && make stop && sleep 2 && rm -rf ./*)

su -c "tar zxf /tmp/smx-agg-tigase.$version.tgz -C ${BASE}" - smx

(cd ${BASE} && make migrate_force  && make start)
